Skip to content

Conversation

@oleonardolima
Copy link
Collaborator

Description

  • use unwrap_or_default() instead of .unwrap(), ideally it should return a specific error variant, it'd be a breaking change though and can be added in a follow-up.
  • it's only possible to use the internal minreq::Error to wrap the serde_json::Error, but not the reqwest::Error as it does not have public constructors.

Notes to the reviewers

I personally wanted to remove the .unwrap() and properly handle the error, though the options I had in mind:

  • (i) adding a new SerdeJson variant is a breaking change; we can do it as a follow-up for 0.13.0
  • (ii) mapping and wrapping it into either minreq/reqwest errors is only possible in minreq, so I thought it's better to keep it standard and use .unwrap_or_default() on both for now.

- use `unwrap_or_default()` instead of `.unwrap()`, ideally it should
  return a specific error variant, it'd be a breaking change though
  and can be added in a follow-up.
- it's only possible to use the internal `minreq::Error` to wrap the
  `serde_json::Error`, but not the `reqwest::Error` as it does not
  have public constructors.
@coveralls
Copy link

coveralls commented Jan 7, 2026

Pull Request Test Coverage Report for Build 20804402127

Details

  • 2 of 5 (40.0%) changed or added relevant lines in 2 files are covered.
  • 1 unchanged line in 1 file lost coverage.
  • Overall coverage increased (+0.05%) to 86.704%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/async.rs 0 1 0.0%
src/blocking.rs 2 4 50.0%
Files with Coverage Reduction New Missed Lines %
src/blocking.rs 1 76.33%
Totals Coverage Status
Change from base Build 20725239190: 0.05%
Covered Lines: 1402
Relevant Lines: 1617

💛 - Coveralls

@luisschwab
Copy link
Member

Agree, we should go with the first approach and then create proper error variants once bitreq is used here.

Copy link
Member

@luisschwab luisschwab left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK c2c5485

@ValuedMammal
Copy link
Contributor

I found 2 more instances of unwrap in src/blocking.rs.

147:                let hex_vec = Vec::from_hex(hex_str).unwrap();
165:                let hex_vec = Vec::from_hex(hex_str).unwrap();

@luisschwab
Copy link
Member

I think this PR only intends to address those added in the submit package PR, but these can be tackled here as well.

@oleonardolima
Copy link
Collaborator Author

Yes, I only had bookmarked the ones added in the submit_package PR, addressed the other two in ea9b5d1

Copy link
Member

@luisschwab luisschwab left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK ea9b5d1

Copy link
Contributor

@ValuedMammal ValuedMammal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK ea9b5d1

@oleonardolima oleonardolima merged commit de249b6 into bitcoindevkit:master Jan 9, 2026
26 checks passed
@github-project-automation github-project-automation bot moved this to Done in BDK Chain Jan 9, 2026
@oleonardolima oleonardolima deleted the refactor/improve-error-handling-and-remove-unwrap branch January 9, 2026 16:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants